package disanshuzu;

import java.util.Scanner;

public class pinjie {
    public static void main(String[] args) {
        int[] arr = {12, 14, 10, 5, 6, 7, 8};//局部变量
        pinjie.outPut(arr,arr.length);
        int[] arr1 = new int[arr.length];
        System.out.println("请输入要移动位置的下标");
        Scanner scanner = new Scanner(System.in);
        int index = scanner.nextInt();//3  0 1 2
        int index1=0;
        //1.保护前index个数据  12, 14, 10, 5, 6, 7, 8 例如输入2 则12 14
        for (int i = 0; i < index; i++)//index=2
        {
            arr1[i] = arr[i];
        }
        //2.从下标第index开始移动位置
        for(int j=index;j<arr.length;j++)//j=2 j<7
        {
            arr[index1++]=arr[j];//
        }
        //3.把保护的数据接上去
        for (int i = 0; i < index; i++)//index<2
        {
            arr[index1++] = arr1[i];
        }
        pinjie.outPut(arr,arr.length);
    }
    public static void outPut(int[] arr, int len)//
    {
        for (int i = 0; i < len; i++) {
            System.out.print(" " + arr[i]);
        }
        System.out.println();
    }

}
